//
//  FirstViewController.m
//  UiView
//
//  Created by qianfeng on 15/7/29.
//  Copyright (c) 2015年 CB. All rights reserved.
//

#import "FirstViewController.h"
#import "SeconedViewController.h"
#import "MyControl.h"
@interface FirstViewController ()
{

    UIView *view1;
    UIView *view2;
    UIView *view3;

}
@end

@implementation FirstViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createButton];
    [self createView];
    
}
-(void)createView
{
    
    view1=[[UIView alloc]initWithFrame:CGRectMake(0, 20, self.view.frame.size.width,20)];
    view1.tag=11;//标志 所有的控件都是有这个属性的，缺省为0；
    view1.backgroundColor=[UIColor orangeColor];
    view2=[[UIView alloc]initWithFrame:CGRectMake(0, 50, self.view.frame.size.width, 20)];
    view2.backgroundColor=[UIColor redColor];
    view2.tag=12;
    view3=[[UIView alloc]initWithFrame:CGRectMake(0, 20, self.view.frame.size.width, 500)];
    view3.backgroundColor=[UIColor yellowColor];
    UILabel *label=[MyControl creatLabelWithFrame:CGRectMake(0, 0, 300, 40) text:@"我是label"];
    [self.view addSubview:view3];
    [self.view addSubview:view1];
    [self.view addSubview:view2];


}
-(void)createButton
{
    UIButton *button=[[UIButton alloc]initWithFrame:CGRectMake(0, 600, self.view.frame.size.width, 30)];
    button.backgroundColor=[UIColor blueColor];
    [button setTitle:@"按钮" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [button setTitleColor:[UIColor greenColor] forState:UIControlStateHighlighted];
    [button addTarget:self action:@selector(onclick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
}
-(void)onclick:(UIButton *)button
{
    static BOOL isShowing=YES;
    if (isShowing) {
        [self.view sendSubviewToBack:view1];
        [self.view sendSubviewToBack:view2];

        isShowing=NO;
    }
    else
    {
        [self.view bringSubviewToFront:view1];
        [self.view bringSubviewToFront:view2];
    isShowing=YES;
    }

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
  
}


@end
